package com.dtkavin.sparkstreaming

import org.apache.log4j.{Level, Logger}
import org.apache.spark.Logging
/**
  * Created by IntelliJ IDEA.
  * Programmer : John Zn
  * Date : 2016/4/19 0019
  * Time : 22:18
  * Discribtion : spark日志输出级别自定义
  */
object SelfLogging extends Logging {
  val log4jInitialized = Logger.getRootLogger.getAllAppenders.hasMoreElements

    def getSelfLoggingLevel(level: String): Unit = {
//      level match {
//        case "WARN" => Logger.getRootLogger.setLevel(Level.WARN)
//        case _ => Logger.getRootLogger.setLevel(Level.INFO)
//      }
      if (!log4jInitialized) {
            logInfo("Setting log level to [WARN] for streaming example." +
              " To override add a custom log4j.properties to the classpath.")
            Logger.getRootLogger.setLevel(Level.WARN)
          }
    }


}
